<?php
/** 初始化项目 */
require '../../app/app.php';
/** 初始化数据库 */
use app\util\Mysql;
$database = Mysql::init();

$adname = $_SESSION["username"];
$client_ip = getClientIP();
$timestamp = time();
if (isset($_GET["uid"])) {
    $uid = $_GET["uid"];
    // 执行删除操作
    $database->delete("text_auth", ["id" => $uid]); //清理文章权限
    $username = $database->select("user_text", "username", ["id" => $uid]);
    $username = $username[0];
    $database->delete("text_main", ["creator" => $username]); //清理文章
    $database->delete("pass_key", ["uid" => $uid]); //清理秘钥
    $database->delete("more_file", ["name" => $username]); //清理文件
    $database->delete("user_text", ["username" => $username]); //清理用户信息
    $content = $adname . "删除了用户：" . $username;
    $database->insert("secure_info", ["user" => $adname, "ip" => $client_ip, "times" => $timestamp, "content" => $content]);
    echo "<script>alert('删除成功!');location.href='/admin/usermt.php';</script>";
}
